package com.changli05._super.exer3;

public class Account {
    private int id;
    private double balance;
    private double annualInterestRate;

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    public double getMonthlyInterestRate() {
        return annualInterestRate/12;
    }
    public void withdraw(double amount){
        if(amount > balance){
            System.out.println("余额不足!");
            System.out.println("您的帐户余额为："+balance);
        }
        else{
            balance -= amount;
            System.out.println("您的帐户余额为:"+balance);
//            System.out.println("月利率为:"+getMonthlyInterestRate());
        }
    }
    public void deposit(double amount){
        if(amount >=0){
            balance += amount;
        }
        else{
            System.out.println("请您输入正确的存款金额!");
        }
    }
}
